<template>
  <el-card class="admin-header">
    <span class="span">售后维修管理系统</span>
    <i class="el-icon-switch-button" v-on:click="logout" style="font-size: 40px;float: right"></i>
  </el-card>
</template>

<script>
import {createRouter} from '../../router'

export default {
  name: 'Header',
  methods: {
    logout() {
      var _this = this
      this.$axios.get('/logout').then(resp => {
        if (resp && resp.data.code === 200) {
          _this.$store.commit('logout')
          _this.$router.replace('/index')
          // 清空路由，防止路由重复加载
          const newRouter = createRouter()
          _this.$router.matcher = newRouter.matcher
        }
      })
    }
  }
}
</script>

<style scoped>
.admin-header {
  height: 80px;
  opacity: 1.85;
  line-height: 40px;
  min-width: 900px;
  background: -webkit-linear-gradient(left,hsl(222deg 73% 49% / 281%),hsl(208deg 265% 44% / 281%),#f3f4f6) no-repeat;
}

.el-icon-switch-button {
  cursor: pointer;
  outline: 0;
}

.span {
  color: #e5e5e5;
  font-size: 30px;
  font-weight: bold;
  position: absolute;
  left: 0px
}
</style>
